//
//  ViewController.swift
//  C002_test_iOS_UI
//
//  Created by yao_yu on 15/5/18.
//  Copyright (c) 2015年 yao_yu. All rights reserved.
//

import UIKit

class MyUIView: UIView {
    override func layoutSubviews() {
        print("MyUIView.即将更新子界面")
    }
}


class ViewController: UIViewController {
    var aView: MyUIView!
    var view2: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        
        aView = MyUIView(frame: CGRectZero)
        view2 = UIView(frame: CGRectZero)
        
        //重复添加多次
        for _ in 1...50{
            view.addSubview(aView)
            view.addSubview(view2)
        }
        //结果, 只添加了一次
        print(view.subviews.count)
        for i in view.subviews{
            print(i)
        }
        
    }
    
    override func viewWillLayoutSubviews() {
        print("UIView.即将更新子界面")

        aView.frame = view.frame
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

